# coding: utf-8
import uuid

from sqlalchemy import BigInteger, Boolean, CHAR, Column, DateTime, Float, Integer, JSON, LargeBinary, Numeric, \
    SmallInteger, String, Text, text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Mapped, mapped_column

from utils.uuid import UUID

Base = declarative_base()
metadata = Base.metadata


class Adapter(Base):
    __tablename__ = 'adapter'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    table = Column(String(100))
    use_same_db = Column(Boolean)
    type = Column(String(100))
    database_type = Column(String(100))
    host = Column(String(100))
    port = Column(Integer)
    user = Column(String(100))
    password = Column(String(150))
    database = Column(String(100))


class Application(Base):
    __tablename__ = 'application'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    logo = Column(String(200))
    homepage_url = Column(String(100))
    description = Column(String(100))
    organization = Column(String(100))
    cert = Column(String(100))
    header_html = Column(Text)
    enable_password = Column(Boolean)
    enable_sign_up = Column(Boolean)
    enable_signin_session = Column(Boolean)
    enable_auto_signin = Column(Boolean)
    enable_code_signin = Column(Boolean)
    enable_saml_compress = Column(Boolean)
    enable_saml_c14n10 = Column(Boolean)
    enable_saml_post_binding = Column(Boolean)
    enable_web_authn = Column(Boolean)
    enable_link_with_email = Column(Boolean)
    org_choice_mode = Column(String(255))
    saml_reply_url = Column(String(100))
    providers = Column(Text)
    signin_methods = Column(String(2000))
    signup_items = Column(String(2000))
    signin_items = Column(Text)
    grant_types = Column(String(1000))
    tags = Column(Text)
    saml_attributes = Column(String(1000))
    client_id = Column(String(100))
    client_secret = Column(String(100))
    redirect_uris = Column(String(1000))
    token_format = Column(String(100))
    token_fields = Column(String(1000))
    expire_in_hours = Column(Integer)
    refresh_expire_in_hours = Column(Integer)
    signup_url = Column(String(200))
    signin_url = Column(String(200))
    forget_url = Column(String(200))
    affiliation_url = Column(String(100))
    terms_of_use = Column(String(100))
    signup_html = Column(Text)
    signin_html = Column(Text)
    theme_data = Column(JSON)
    footer_html = Column(Text)
    form_css = Column(Text)
    form_css_mobile = Column(Text)
    form_offset = Column(Integer)
    form_side_html = Column(Text)
    form_background_url = Column(String(200))
    failed_signin_limit = Column(Integer)
    failed_signin_frozen_time = Column(Integer)


class CasbinApiRule(Base):
    __tablename__ = 'casbin_api_rule'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".casbin_api_rule_id_seq'::regclass)"))
    ptype = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v0 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v1 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v2 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v3 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v4 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v5 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))


class CasbinRule(Base):
    __tablename__ = 'casbin_rule'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".casbin_rule_id_seq'::regclass)"))
    ptype = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v0 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v1 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v2 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v3 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v4 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v5 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))


class CasbinUserRule(Base):
    __tablename__ = 'casbin_user_rule'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".casbin_user_rule_id_seq'::regclass)"))
    ptype = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v0 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v1 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v2 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v3 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v4 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v5 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))


class Cert(Base):
    __tablename__ = 'cert'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    scope = Column(String(100))
    type = Column(String(100))
    crypto_algorithm = Column(String(100))
    bit_size = Column(Integer)
    expire_in_years = Column(Integer)
    certificate = Column(Text)
    private_key = Column(Text)


class CmsAlertMessage(Base):
    __tablename__ = 'cms_alert_message'
    __table_args__ = {'schema': 'public', 'comment': '告警信息表\r\n根据告警规则对比设备坐标产生告警信息'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_alert_id_seq'::regclass)"))
    car_id = Column(String(32), nullable=False, comment='车辆编码')
    fence_id = Column(String(32), nullable=False, comment='围栏编码')
    alert_type = Column(String(32), comment='告警类型（in 进入，out 离开） ')
    alert_msg = Column(String(255), comment='告警信息')
    handle = Column(String(255), comment='处理')
    handle_by = Column(String(255), comment='处理人')
    car_number = Column(String(64), nullable=False, comment='车牌号')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    fence_name = Column(String(32), comment='围栏名称')
    location = Column(String(32), comment='位置')


class CmsAlertRule(Base):
    __tablename__ = 'cms_alert_rule'
    __table_args__ = {'schema': 'public', 'comment': '告警规则表\r\n根据电子围栏设置告警规则\r\n'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_monitor_id_seq'::regclass)"))
    fence_id = Column(String(32), comment='围栏编码')
    type = Column(String(32), comment='监控类型（in 进入，out 离开） ')
    rule_name = Column(String(32), comment='规则名称')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsCar(Base):
    __tablename__ = 'cms_car'
    __table_args__ = {'schema': 'public', 'comment': '车辆信息'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_car_id_seq'::regclass)"))
    car_id = Column(String(32), nullable=False, comment='车辆编码')
    car_number = Column(String(32), nullable=False, comment='车牌号')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    car_image = Column(String(255), comment='车辆照片')
    car_permit_image = Column(String(255), comment='行驶证照片')
    car_type = Column(String(64), comment='车辆类型')
    car_brand = Column(String(64), comment='车辆品牌')
    car_model = Column(String(64), comment='车辆型号')
    car_head = Column(String(64), comment='车辆负责人')
    property_right = Column(String(64), comment='产权（public 公有，private 私有）')
    energy_type = Column(String(64), comment='能源类型（汽油，柴油，电）')
    buy_date = Column(DateTime, comment='购买日期')
    vin_no = Column(String(64), comment='车架号')
    engine_o = Column(String(64), comment='发动机号')
    charging_type = Column(String(64), comment='计费类型')
    remark = Column(String(255), comment='备注')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    car_department_id = Column(String, comment='部门id')
    car_team_id = Column(String, comment='车队id')
    device_id = Column(String, comment='设备id')
    gaode_tid = Column(String, comment='高德设备id')


class CmsCarTrack(Base):
    __tablename__ = 'cms_car_track'
    __table_args__ = {'schema': 'public',
                      'comment': '车辆轨迹表\r\n根据用车记录生成车辆轨迹，用车状态为进行中时，创建车辆轨迹，直到用车完成，车辆轨迹结束'}

    id = Column(Integer, primary_key=True, default=int(UUID().uuid()), comment='主键')
    car_id = Column(String(100), nullable=False, comment='车辆编码')
    device_id = Column(String(100), nullable=False, comment='设备编码')
    record_time = Column(DateTime, comment='记录时间')
    car_number = Column(String(64), comment='车牌号')
    lon = Column(String, comment='经度')
    lat = Column(String, comment='纬度')
    height = Column(BigInteger, comment='高度')
    speed = Column(BigInteger, comment='速度')
    direction = Column(BigInteger, comment='方向')
    track_id = Column(String(64), nullable=False, comment='轨迹编码')
    execute_id = Column(String(64), nullable=False, comment='订单执行编码')
    driver_id = Column(String(64), comment='司机编码')
    driver_name = Column(String(64), comment='司机名称')
    gaode_track_id = Column(String(64), comment='高德轨迹编码')
    track_name = Column(String(64), comment='轨迹名称')
    service_id = Column(String(64), comment='服务编码')
    terminal_id = Column(String(64), comment='终端编码')
    state = Column(Integer, comment='状态（0 失效，1 有效）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间', server_default=text("CURRENT_TIMESTAMP"))
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')


class CmsCarType(Base):
    __tablename__ = 'cms_car_type'
    __table_args__ = {'schema': 'public', 'comment': '车辆类型'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_car_type_id_seq'::regclass)"))
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    car_type_id = Column(String(32), comment='车辆类型编码')
    car_type_name = Column(String(32), comment='车辆类型')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsDepartment(Base):
    __tablename__ = 'cms_department'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_department_id_seq'::regclass)"))
    department_id = Column(String(32), nullable=False, comment='部门编码')
    department_name = Column(String(64), nullable=False, comment='部门名称')
    department_head = Column(String(32), nullable=False, comment='部门负责人')
    phone = Column(String(32), nullable=False, comment='部门联系方式')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    parent_id = Column(String(32), comment='上级部门编码')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsDevice(Base):
    __tablename__ = 'cms_device'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_device_id_seq'::regclass)"))
    device_id = Column(String(32), nullable=False, comment='设备编码')
    device_type = Column(String(32), nullable=False, comment='设备类型（定位 ）')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    car_device_no = Column(String(32), comment='车载设备号')
    online_date = Column(DateTime, comment='上线日期')
    warranty_period = Column(DateTime, comment='保修期')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    device_name = Column(String(64), comment='设备名称')


class CmsDeviceDatum(Base):
    __tablename__ = 'cms_device_data'
    __table_args__ = {'schema': 'public', 'comment': '设备数据'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_device_data_id_seq'::regclass)"))
    device_id = Column(String(32), nullable=False, comment='设备编码')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    device_data = Column(String, comment='设备数据')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsDriver(Base):
    __tablename__ = 'cms_driver'
    __table_args__ = {'schema': 'public', 'comment': '驾驶员信息'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_driver_id_seq'::regclass)"))
    driver_id = Column(String(32), nullable=False, comment='驾驶员编码')
    driver_name = Column(String(32), nullable=False, comment='驾驶员姓名')
    driver_model = Column(String(32), nullable=False, comment='准驾车型')
    phone = Column(String(32), nullable=False, comment='手机号')
    identity_card = Column(String(64), nullable=False, comment='身份证号')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    experation_begin = Column(DateTime, comment='驾照有效期开始时间')
    experation_end = Column(DateTime, comment='驾照有效期结束时间')
    certificate_no = Column(String(255), comment='从业资格证号')
    certificate_image = Column(String(255), comment='从业资格证图片')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsElectricFence(Base):
    __tablename__ = 'cms_electric_fence'
    __table_args__ = {'schema': 'public', 'comment': '电子围栏'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_electric_fence_id_seq'::regclass)"))
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    electric_fence_id = Column(String(32), comment='电子围栏编码')
    name = Column(String(255), comment='围栏名称')
    type = Column(String(255), comment='围栏监控类型')
    area = Column(String(255), comment='区域')
    customize = Column(String(255), comment='自定义区域')
    remark = Column(String(255), comment='备注')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsFleet(Base):
    __tablename__ = 'cms_fleet'
    __table_args__ = {'schema': 'public', 'comment': '车队'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_fleet_id_seq'::regclass)"))
    fleet_id = Column(String(32), nullable=False, comment='车队编码')
    fleet_name = Column(String(64), nullable=False, comment='车队名称')
    manager = Column(String(32), nullable=False, comment='车队管理员')
    manager_phone = Column(String(32), nullable=False, comment='管理员手机号')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    illustrate = Column(String(255), comment='说明')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsGaodeFence(Base):
    __tablename__ = 'cms_gaode_fence'
    __table_args__ = {'schema': 'public', 'comment': '高德围栏'}

    id: Mapped[str] = mapped_column(BigInteger, primary_key=True)
    service_id = Column(String(32), nullable=False, comment='服务编码')
    fence_id = Column(String(32), nullable=False, comment='围栏编码')
    fence_type = Column(String(32), nullable=False,
                        comment='围栏类型（circle 圆形，polygon 多边形，polyline 线性，district 行政区）')
    fence_name = Column(String(32), nullable=False,
                        comment='围栏名称（格式支持中文、英文大小写字母、英文下划线"_"、英文横线"-"和数字）')
    fence_desc = Column(String(64), nullable=False, comment='围栏描述')
    circle_center = Column(String(255), comment='围栏中心点坐标，圆形必填')
    circle_radius = Column(String(255), comment='围栏半径\r\n\r\n围栏半径 单位：米，整数，取值范[1,50000]；圆形必填')
    polygon_points = Column(String(255),
                            comment='多边形顶点坐标 格式 X1,Y1;X2,Y2;...\r\n\r\n顶点顺序可按顺时针或逆时针排列；\r\n\r\n1. 普通地理围栏：顶点个数在3-100个之间，外接矩形面积<100平方公里；\r\n2. 大范围地理围栏：顶点个数在3-100个之间，外接矩形面积小于1000平方公里')
    polyline_points = Column(String(255),
                             comment='线上各点坐标 格式 X1,Y1;X2,Y2;...\r\n\r\n线路总长度<500KM，坐标点个数取值范围 [2，100]')
    polyline_bufferradius = Column(Integer, comment='沿线偏移距离 单位：米\r\n\r\n取值范围 [1，300]')
    district_adcode = Column(String(255), comment='行政区域编码')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    alarm_type = Column(String(256), comment='围栏类型（进入监控，离开监控）')


class CmsGaodeFenceTerminal(Base):
    __tablename__ = 'cms_gaode_fence_terminal'
    __table_args__ = {'schema': 'public', 'comment': '高德围栏-终端对应表'}

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, default=int(UUID().uuid()))
    service_id = Column(String(32), nullable=False, comment='服务编码')
    fence_id = Column(String(32), nullable=False, comment='围栏编码')
    terminal_id = Column(String(32), nullable=False, comment='终端编码')
    state = Column(String(32), comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    tid = Column(String(32), comment='高德设备id')


class CmsGaodePoint(Base):
    __tablename__ = 'cms_gaode_point'
    __table_args__ = {'schema': 'public', 'comment': '高德轨迹点'}

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, default=int(UUID().uuid()))
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsGaodeService(Base):
    __tablename__ = 'cms_gaode_service'
    __table_args__ = {'schema': 'public', 'comment': '高德服务'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_gaode_service_seq'::regclass)"))
    service_id = Column(String(32), nullable=False, comment='服务编码')
    service_name = Column(String(32), nullable=False,
                          comment='服务名称（格式支持中文、英文大小写字母、英文下划线"_"、英文横线"-"和数字）')
    service_desc = Column(String(32), nullable=False, comment='服务描述')
    state = Column(Integer, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsGaodeTerminal(Base):
    __tablename__ = 'cms_gaode_terminal'
    __table_args__ = {'schema': 'public', 'comment': '高德终端'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_gaode_terminal_seq'::regclass)"))
    service_id = Column(String(32), nullable=False, comment='服务编码')
    terminal_id = Column(String(32), nullable=False,
                         comment='终端编码（格式支持中文、英文大小写字母、英文下划线"_"、英文横线"-"和数字）')
    terminal_name = Column(String(32), nullable=False,
                           comment='终端名称（命名规则：车牌号_车辆编码_设备编码）（格式支持中文、英文大小写字母、英文下划线"_"、英文横线"-"和数字）')
    terminal_desc = Column(String(64), nullable=False, comment='终端描述')
    state = Column(Integer, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    car_id = Column(String(64), comment='车辆编码')
    device_id = Column(String(64), comment='设备编码')
    car_number = Column(String(64), comment='车牌号')


class CmsGaodeTrace(Base):
    __tablename__ = 'cms_gaode_trace'
    __table_args__ = {'schema': 'public', 'comment': '高德轨迹'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_gaode_trace_seq'::regclass)"))
    service_id = Column(String(32), nullable=False, comment='服务编码')
    terminal_id = Column(String(32), nullable=False, comment='终端编码')
    trace_id = Column(String(32), nullable=False, comment='轨迹编码')
    trace_name = Column(String(64), nullable=False,
                        comment='轨迹名称（命名规则：车牌号_订单号，跟高德轨迹名称保持一致）（格式支持中文、英文大小写字母、英文下划线"_"、英文横线"-"和数字）')
    distance = Column(BigInteger, nullable=False, comment='轨迹长度，单位：米')
    time = Column(BigInteger, nullable=False, comment='轨迹持续时间，单位：毫秒')
    count = Column(BigInteger, nullable=False, comment='轨迹点数量')
    state = Column(Integer, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    execute_id = Column(String(32), comment='订单执行id')

class CmsGaodeTraceDay(Base):
    __tablename__ = 'cms_gaode_trace_day'
    __table_args__ = {'schema': 'public', 'comment': '高德轨迹'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_gaode_trace_seq'::regclass)"))
    service_id = Column(String(32), nullable=False, comment='服务编码')
    terminal_id = Column(String(32), nullable=False, comment='终端编码')
    trace_id = Column(String(32), nullable=False, comment='轨迹编码')
    trace_name = Column(String(64), nullable=False,
                        comment='轨迹名称（命名规则：车牌号_订单号，跟高德轨迹名称保持一致）（格式支持中文、英文大小写字母、英文下划线"_"、英文横线"-"和数字）')
    distance = Column(BigInteger, nullable=False, comment='轨迹长度，单位：米')
    time = Column(BigInteger, nullable=False, comment='轨迹持续时间，单位：毫秒')
    count = Column(BigInteger, nullable=False, comment='轨迹点数量')
    state = Column(Integer, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    execute_id = Column(String(32), comment='订单执行id')


class CmsManager(Base):
    __tablename__ = 'cms_manager'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_manager_id_seq'::regclass)"))
    user_id = Column(String(32), nullable=False, comment='用户编码')
    phone = Column(String(32), nullable=False, comment='手机号')
    name = Column(String(32), nullable=False, comment='姓名')
    role_id = Column(String(32), nullable=False, comment='角色编码')
    state = Column(Integer, nullable=False, comment='状态（0 未启用，1 启用）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsOrder(Base):
    __tablename__ = 'cms_order'
    __table_args__ = {'schema': 'public', 'comment': '用车订单'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_order_id_seq'::regclass)"))
    state = Column(Integer, nullable=False,
                   comment='状态（1 待审核，2 待调度，3 审核驳回，4  待确认，5 待开始，6 进行中，7 已完结，8 已取消）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    order_id = Column(String(32), comment='单号')
    user_id = Column(String(32), comment='用车人')
    phone = Column(String(32), comment='联系电话')
    department_id = Column(String(32), comment='用车部门')
    rading_count = Column(Integer, comment='乘坐人数')
    start = Column(String(255), comment='出发地（可以有多个）')
    destination = Column(String(255), comment='目的地（可以有多个）')
    plan_begin_time = Column(DateTime, comment='预计出车时间')
    plan_end_time = Column(DateTime, comment='预计回车时间')
    use_car_type = Column(String(32), comment='用车类型（个人用车，领导用车，客户用车）')
    dispatch_type = Column(String(32), comment='调度类型（普通调度，应急调度）')
    remark = Column(String(255), comment='用车备注')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    car_count = Column(Integer, comment='用车数量')
    expected_mileage = Column(Numeric, comment='预计里程')
    use_user_id = Column(String, comment='用车人')


class CmsOrderApprove(Base):
    __tablename__ = 'cms_order_approve'
    __table_args__ = {'schema': 'public', 'comment': '用车审批'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_order_approve_id_seq'::regclass)"))
    order_id = Column(String(32), nullable=False, comment='单号')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    state = Column(Integer, comment='审批状态')
    remark = Column(String(255), comment='审批备注')
    approve_id = Column(String(32), comment='审批人')
    approve_time = Column(DateTime, comment='审批时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsOrderBill(Base):
    __tablename__ = 'cms_order_bill'
    __table_args__ = {'schema': 'public', 'comment': '用车账单'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_order_bill_id_seq'::regclass)"))
    state = Column(String(16), nullable=False, comment='状态（未结算，已结算）')
    order_id = Column(String(32), comment='单号')
    car_id = Column(String(32), comment='车辆编码')
    driver_id = Column(String(32), comment='驾驶员编码')
    system_mileage = Column(Numeric(10, 2), comment='系统里程')
    sheet_mileage = Column(Numeric(10, 2), comment='仪表里程')
    expenses = Column(Numeric(10, 2), comment='费用')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsOrderDispatch(Base):
    __tablename__ = 'cms_order_dispatch'
    __table_args__ = {'schema': 'public', 'comment': '用车调度'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_order_dispatch_id_seq'::regclass)"))
    order_id = Column(String(32), nullable=False, comment='单号')
    car_id = Column(String(32), nullable=False, comment='车辆编码')
    driver_id = Column(String(32), nullable=False, comment='驾驶员编码')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    reason = Column(String(1024), comment='拒绝原因')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    rading_count = Column(Integer, comment='乘坐人数')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsOrderExecute(Base):
    __tablename__ = 'cms_order_execute'
    __table_args__ = {'schema': 'public', 'comment': '用车履约'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_order_execute_id_seq'::regclass)"))
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    order_id = Column(String(32), comment='单号')
    car_id = Column(String(32), nullable=False, comment='车辆编码')
    driver_id = Column(String(32), nullable=False, comment='驾驶员编码')
    rading_count = Column(Integer, comment='乘坐人数')
    reality_begin_time = Column(DateTime, comment='实际出车时间')
    reality_end_time = Column(DateTime, comment='实际回车时间')
    start_mileage = Column(Numeric(10, 2), comment='任务开始里程')
    end_mileage = Column(Numeric(10, 2), comment='任务结束里程')
    sheet_mileage = Column(Numeric(10, 2), comment='仪表里程')
    start_file = Column(String(32), comment='任务开始附件')
    end_file = Column(String(32), comment='任务结束附件')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsPost(Base):
    __tablename__ = 'cms_post'
    __table_args__ = {'schema': 'public', 'comment': '岗位'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_post_id_seq'::regclass)"))
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    post_id = Column(String(32), comment='岗位编码')
    post_name = Column(String(32), comment='岗位名称')
    state = Column(Integer, comment='状态（0 失效，1 有效）')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class CmsRole(Base):
    __tablename__ = 'cms_role'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True, server_default=text("nextval('\"public\".cms_role_id_seq'::regclass)"))
    role_id = Column(String(32), nullable=False, comment='角色编码')
    role_name = Column(String(64), nullable=False, comment='角色名称')
    sort = Column(Integer, nullable=False, comment='排序（0-99，默认0，越大越靠前）')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False)
    illustrate = Column(String(255), comment='角色说明')
    update_time = Column(DateTime)


class CmsTerminalPoint(Base):
    __tablename__ = 'cms_terminal_point'
    __table_args__ = {'schema': 'public', 'comment': '设备轨迹点信息'}

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, default=int(UUID().uuid()))
    terminal_id = Column(String(64), nullable=False, comment='终端')
    lon = Column(String(64), comment='经度')
    lat = Column(String(64), comment='纬度')
    height = Column(BigInteger, comment='高度')
    speed = Column(BigInteger, comment='速度')
    direction = Column(BigInteger, comment='方向')
    up_time = Column(DateTime, comment='上传时间')
    state = Column(Integer, nullable=False, comment='状态（0 失效，1 有效）')
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')
    device_id = Column(String(64), nullable=False, comment='设备编码')


class CmsUseCarType(Base):
    __tablename__ = 'cms_use_car_type'
    __table_args__ = {'schema': 'public', 'comment': '用车类型'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".cms_use_car_type_id_seq'::regclass)"))
    create_time = Column(DateTime, nullable=False, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    use_car_type_id = Column(String(32), comment='用车类型编码')
    use_car_type_name = Column(String(32), comment='用车类型')
    state = Column(Integer, comment='状态（0 失效，1有效）')
    create_by = Column(String(32), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')
    update_by = Column(String(32), comment='修改人')


class Enforcer(Base):
    __tablename__ = 'enforcer'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    updated_time = Column(String(100))
    display_name = Column(String(100))
    description = Column(String(100))
    model = Column(String(100))
    adapter = Column(String(100))
    enforcer = Column(Text)


class GenTable(Base):
    __tablename__ = 'gen_table'
    __table_args__ = {'schema': 'public', 'comment': '代码生成业务表'}

    table_id = Column(BigInteger, primary_key=True, comment='编号')
    table_name = Column(String(200), comment='表名称')
    table_comment = Column(String(500), comment='表描述')
    sub_table_name = Column(String(64), comment='关联子表的表名')
    sub_table_fk_name = Column(String(64), comment='子表关联的外键名')
    class_name = Column(String(100), comment='实体类名称')
    tpl_category = Column(String(200), comment='使用的模板（crud单表操作 tree树表操作）')
    package_name = Column(String(100), comment='生成包路径')
    module_name = Column(String(30), comment='生成模块名')
    business_name = Column(String(30), comment='生成业务名')
    function_name = Column(String(50), comment='生成功能名')
    function_author = Column(String(50), comment='生成功能作者')
    gen_type = Column(CHAR(1), comment='生成代码方式（0zip压缩包 1自定义路径）')
    gen_path = Column(String(200), comment='生成路径（不填默认项目路径）')
    options = Column(String(1000), comment='其它生成选项')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class GenTableColumn(Base):
    __tablename__ = 'gen_table_column'
    __table_args__ = {'schema': 'public', 'comment': '代码生成业务表字段'}

    column_id = Column(BigInteger, primary_key=True, comment='编号')
    table_id = Column(String(64), comment='归属表编号')
    column_name = Column(String(200), comment='列名称')
    column_comment = Column(String(500), comment='列描述')
    column_type = Column(String(100), comment='列类型')
    java_type = Column(String(500), comment='JAVA类型')
    java_field = Column(String(200), comment='JAVA字段名')
    is_pk = Column(CHAR(1), comment='是否主键（1是）')
    is_increment = Column(CHAR(1), comment='是否自增（1是）')
    is_required = Column(CHAR(1), comment='是否必填（1是）')
    is_insert = Column(CHAR(1), comment='是否为插入字段（1是）')
    is_edit = Column(CHAR(1), comment='是否编辑字段（1是）')
    is_list = Column(CHAR(1), comment='是否列表字段（1是）')
    is_query = Column(CHAR(1), comment='是否查询字段（1是）')
    query_type = Column(String(200), comment='查询方式（等于、不等于、大于、小于、范围）')
    html_type = Column(String(200), comment='显示类型（文本框、文本域、下拉框、复选框、单选框、日期控件）')
    dict_type = Column(String(200), comment='字典类型')
    sort = Column(Integer, comment='排序')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')


class Group(Base):
    __tablename__ = 'group'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False, unique=True)
    created_time = Column(String(100))
    updated_time = Column(String(100))
    display_name = Column(String(100))
    manager = Column(String(100))
    contact_email = Column(String(100))
    type = Column(String(100))
    parent_id = Column(String(100))
    is_top_group = Column(Boolean)
    title = Column(String(255))
    key = Column(String(255))
    children = Column(Text)
    is_enabled = Column(Boolean)


class Invitation(Base):
    __tablename__ = 'invitation'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    updated_time = Column(String(100))
    display_name = Column(String(100))
    code = Column(String(100), index=True)
    is_regexp = Column(Boolean)
    quota = Column(Integer)
    used_count = Column(Integer)
    application = Column(String(100))
    username = Column(String(100))
    email = Column(String(100))
    phone = Column(String(100))
    signup_group = Column(String(100))
    default_code = Column(String(100))
    state = Column(String(100))


class Ldap(Base):
    __tablename__ = 'ldap'
    __table_args__ = {'schema': 'public'}

    id = Column(String(100), primary_key=True)
    owner = Column(String(100))
    created_time = Column(String(100))
    server_name = Column(String(100))
    host = Column(String(100))
    port = Column(Integer)
    enable_ssl = Column(Boolean)
    username = Column(String(100))
    password = Column(String(100))
    base_dn = Column(String(100))
    filter = Column(String(200))
    filter_fields = Column(String(100))
    auto_sync = Column(Integer)
    last_sync = Column(String(100))


class Model(Base):
    __tablename__ = 'model'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    description = Column(String(100))
    model_text = Column(Text)


class Organization(Base):
    __tablename__ = 'organization'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    website_url = Column(String(100))
    logo = Column(String(200))
    logo_dark = Column(String(200))
    favicon = Column(String(100))
    password_type = Column(String(100))
    password_salt = Column(String(100))
    password_options = Column(String(100))
    country_codes = Column(String(200))
    default_avatar = Column(String(200))
    default_application = Column(String(100))
    tags = Column(Text)
    languages = Column(String(255))
    theme_data = Column(JSON)
    master_password = Column(String(100))
    default_password = Column(String(100))
    master_verification_code = Column(String(100))
    init_score = Column(Integer)
    enable_soft_deletion = Column(Boolean)
    is_profile_public = Column(Boolean)
    mfa_items = Column(String(300))
    account_items = Column(String(5000))


class Payment(Base):
    __tablename__ = 'payment'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    provider = Column(String(100))
    type = Column(String(100))
    product_name = Column(String(100))
    product_display_name = Column(String(100))
    detail = Column(String(255))
    tag = Column(String(100))
    currency = Column(String(100))
    price = Column(Float(53))
    return_url = Column(String(1000))
    user = Column(String(100))
    person_name = Column(String(100))
    person_id_card = Column(String(100))
    person_email = Column(String(100))
    person_phone = Column(String(100))
    invoice_type = Column(String(100))
    invoice_title = Column(String(100))
    invoice_tax_id = Column(String(100))
    invoice_remark = Column(String(100))
    invoice_url = Column(String(255))
    out_order_id = Column(String(100))
    pay_url = Column(String(2000))
    success_url = Column(String(2000))
    state = Column(String(100))
    message = Column(String(2000))


class Permission(Base):
    __tablename__ = 'permission'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    description = Column(String(100))
    users = Column(Text)
    groups = Column(Text)
    roles = Column(Text)
    domains = Column(Text)
    model = Column(String(100))
    adapter = Column(String(100))
    resource_type = Column(String(100))
    resources = Column(Text)
    actions = Column(Text)
    effect = Column(String(100))
    is_enabled = Column(Boolean)
    submitter = Column(String(100))
    approver = Column(String(100))
    approve_time = Column(String(100))
    state = Column(String(100))


class PermissionRule(Base):
    __tablename__ = 'permission_rule'
    __table_args__ = {'schema': 'public'}

    id = Column(BigInteger, primary_key=True,
                server_default=text("nextval('\"public\".permission_rule_id_seq'::regclass)"))
    ptype = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v0 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v1 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v2 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v3 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v4 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))
    v5 = Column(String(100), nullable=False, index=True, server_default=text("''::character varying"))


class Plan(Base):
    __tablename__ = 'plan'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    description = Column(String(100))
    price = Column(Float(53))
    currency = Column(String(100))
    period = Column(String(100))
    product = Column(String(100))
    payment_providers = Column(String(100))
    is_enabled = Column(Boolean)
    role = Column(String(100))


class Pricing(Base):
    __tablename__ = 'pricing'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    description = Column(String(100))
    plans = Column(Text)
    is_enabled = Column(Boolean)
    trial_duration = Column(Integer)
    application = Column(String(100))


class Product(Base):
    __tablename__ = 'product'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    image = Column(String(100))
    detail = Column(String(1000))
    description = Column(String(200))
    tag = Column(String(100))
    currency = Column(String(100))
    price = Column(Float(53))
    quantity = Column(Integer)
    sold = Column(Integer)
    providers = Column(String(255))
    return_url = Column(String(1000))
    state = Column(String(100))


class Provider(Base):
    __tablename__ = 'provider'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False, unique=True)
    created_time = Column(String(100))
    display_name = Column(String(100))
    category = Column(String(100))
    type = Column(String(100))
    sub_type = Column(String(100))
    method = Column(String(100))
    client_id = Column(String(200))
    client_secret = Column(String(3000))
    client_id2 = Column(String(100))
    client_secret2 = Column(String(500))
    cert = Column(String(100))
    custom_auth_url = Column(String(200))
    custom_token_url = Column(String(200))
    custom_user_info_url = Column(String(200))
    custom_logo = Column(String(200))
    scopes = Column(String(100))
    user_mapping = Column(String(500))
    host = Column(String(100))
    port = Column(Integer)
    disable_ssl = Column(Boolean)
    title = Column(String(100))
    content = Column(String(2000))
    receiver = Column(String(100))
    region_id = Column(String(100))
    sign_name = Column(String(100))
    template_code = Column(String(100))
    app_id = Column(String(100))
    endpoint = Column(String(1000))
    intranet_endpoint = Column(String(100))
    domain = Column(String(100))
    bucket = Column(String(100))
    path_prefix = Column(String(100))
    metadata_ = Column('metadata', Text)
    id_p = Column(Text)
    issuer_url = Column(String(100))
    enable_sign_authn_request = Column(Boolean)
    provider_url = Column(String(200))


class RadiusAccounting(Base):
    __tablename__ = 'radius_accounting'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(DateTime)
    username = Column(String(255), index=True)
    service_type = Column(BigInteger)
    nas_id = Column(String(255))
    nas_ip_addr = Column(String(255))
    nas_port_id = Column(String(255))
    nas_port_type = Column(BigInteger)
    nas_port = Column(BigInteger)
    framed_ip_addr = Column(String(255))
    framed_ip_netmask = Column(String(255))
    acct_session_id = Column(String(255), index=True)
    acct_session_time = Column(BigInteger)
    acct_input_total = Column(BigInteger)
    acct_output_total = Column(BigInteger)
    acct_input_packets = Column(BigInteger)
    acct_output_packets = Column(BigInteger)
    acct_terminate_cause = Column(BigInteger)
    last_update = Column(DateTime)
    acct_start_time = Column(DateTime, index=True)
    acct_stop_time = Column(DateTime, index=True)


class Record(Base):
    __tablename__ = 'record'
    __table_args__ = {'schema': 'public'}

    id = Column(Integer, primary_key=True, server_default=text("nextval('\"public\".record_id_seq'::regclass)"))
    owner = Column(String(100), index=True)
    name = Column(String(100), index=True)
    created_time = Column(String(100))
    organization = Column(String(100))
    client_ip = Column(String(100))
    user = Column(String(100))
    method = Column(String(100))
    request_uri = Column(String(1000))
    action = Column(String(1000))
    language = Column(String(100))
    object = Column(Text)
    response = Column(Text)
    is_triggered = Column(Boolean)


class Resource(Base):
    __tablename__ = 'resource'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(180), primary_key=True, nullable=False)
    created_time = Column(String(100))
    user = Column(String(100))
    provider = Column(String(100))
    application = Column(String(100))
    tag = Column(String(100))
    parent = Column(String(100))
    file_name = Column(String(255))
    file_type = Column(String(100))
    file_format = Column(String(100))
    file_size = Column(Integer)
    url = Column(String(255))
    description = Column(String(255))


class Role(Base):
    __tablename__ = 'role'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    description = Column(String(100))
    users = Column(Text)
    groups = Column(Text)
    roles = Column(Text)
    domains = Column(Text)
    is_enabled = Column(Boolean)


class Session(Base):
    __tablename__ = 'session'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    application = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    session_id = Column(Text)


class Subscription(Base):
    __tablename__ = 'subscription'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    display_name = Column(String(100))
    created_time = Column(String(100))
    description = Column(String(100))
    user = Column(String(100))
    pricing = Column(String(100))
    plan = Column(String(100))
    payment = Column(String(100))
    start_time = Column(DateTime)
    end_time = Column(DateTime)
    period = Column(String(100))
    state = Column(String(100))


class Syncer(Base):
    __tablename__ = 'syncer'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    organization = Column(String(100))
    type = Column(String(100))
    database_type = Column(String(100))
    ssl_mode = Column(String(100))
    ssh_type = Column(String(100))
    host = Column(String(100))
    port = Column(Integer)
    user = Column(String(100))
    password = Column(String(150))
    ssh_host = Column(String(100))
    ssh_port = Column(Integer)
    ssh_user = Column(String(100))
    ssh_password = Column(String(150))
    cert = Column(String(100))
    database = Column(String(100))
    table = Column(String(100))
    table_columns = Column(Text)
    affiliation_table = Column(String(100))
    avatar_base_url = Column(String(100))
    error_text = Column(Text)
    sync_interval = Column(Integer)
    is_read_only = Column(Boolean)
    is_enabled = Column(Boolean)


class SysConfig(Base):
    __tablename__ = 'sys_config'
    __table_args__ = {'schema': 'public', 'comment': '参数配置表'}

    config_id = Column(Integer, primary_key=True, comment='参数主键')
    config_name = Column(String(100), comment='参数名称')
    config_key = Column(String(100), comment='参数键名')
    config_value = Column(String(500), comment='参数键值')
    config_type = Column(CHAR(1), comment='系统内置（Y是 N否）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class SysDept(Base):
    __tablename__ = 'sys_dept'
    __table_args__ = {'schema': 'public', 'comment': '部门表'}

    dept_id = Column(BigInteger, primary_key=True, comment='部门id')
    parent_id = Column(BigInteger, comment='父部门id')
    ancestors = Column(String(50), comment='祖级列表')
    dept_name = Column(String(30), comment='部门名称')
    order_num = Column(Integer, comment='显示顺序')
    leader = Column(String(20), comment='负责人')
    phone = Column(String(11), comment='联系电话')
    email = Column(String(50), comment='邮箱')
    status = Column(CHAR(1), comment='部门状态（0正常 1停用）')
    del_flag = Column(CHAR(1), comment='删除标志（0代表存在 2代表删除）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')


class SysDictDatum(Base):
    __tablename__ = 'sys_dict_data'
    __table_args__ = {'schema': 'public', 'comment': '字典数据表'}

    dict_code = Column(BigInteger, primary_key=True, comment='字典编码')
    dict_sort = Column(Integer, comment='字典排序')
    dict_label = Column(String(100), comment='字典标签')
    dict_value = Column(String(100), comment='字典键值')
    dict_type = Column(String(100), comment='字典类型')
    css_class = Column(String(100), comment='样式属性（其他样式扩展）')
    list_class = Column(String(100), comment='表格回显样式')
    is_default = Column(CHAR(1), comment='是否默认（Y是 N否）')
    status = Column(CHAR(1), comment='状态（0正常 1停用）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class SysDictType(Base):
    __tablename__ = 'sys_dict_type'
    __table_args__ = {'schema': 'public', 'comment': '字典类型表'}

    dict_id = Column(BigInteger, primary_key=True, comment='字典主键')
    dict_name = Column(String(100), comment='字典名称')
    dict_type = Column(String(100), unique=True, comment='字典类型')
    status = Column(CHAR(1), comment='状态（0正常 1停用）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class SysJob(Base):
    __tablename__ = 'sys_job'
    __table_args__ = {'schema': 'public', 'comment': '定时任务调度表'}

    job_id = Column(BigInteger, primary_key=True, nullable=False, comment='任务ID')
    job_name = Column(String(64), primary_key=True, nullable=False, comment='任务名称')
    job_group = Column(String(64), primary_key=True, nullable=False, comment='任务组名')
    job_executor = Column(String(64), primary_key=True, nullable=False, comment='任务执行器')
    invoke_target = Column(String(500), nullable=False, comment='调用目标字符串')
    job_args = Column(String(255), comment='位置参数')
    job_kwargs = Column(String(255), comment='关键字参数')
    cron_expression = Column(String(255), comment='cron执行表达式')
    misfire_policy = Column(String(20), comment='计划执行错误策略（1立即执行 2执行一次 3放弃执行）')
    concurrent = Column(CHAR(1), comment='是否并发执行（0允许 1禁止）')
    status = Column(SmallInteger, comment='状态（0正常 1暂停）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注信息')


class SysJobLog(Base):
    __tablename__ = 'sys_job_log'
    __table_args__ = {'schema': 'public', 'comment': '定时任务调度日志表'}

    job_log_id = Column(BigInteger, primary_key=True, comment='任务日志ID')
    job_name = Column(String(64), nullable=False, comment='任务名称')
    job_group = Column(String(64), nullable=False, comment='任务组名')
    job_executor = Column(String(64), nullable=False, comment='任务执行器')
    invoke_target = Column(String(500), nullable=False, comment='调用目标字符串')
    job_args = Column(String(255), comment='位置参数')
    job_kwargs = Column(String(255), comment='关键字参数')
    job_trigger = Column(String(255), comment='任务触发器')
    job_message = Column(String(500), comment='日志信息')
    status = Column(SmallInteger, comment='执行状态（0正常 1失败）')
    exception_info = Column(String(2000), comment='异常信息')
    create_time = Column(DateTime, comment='创建时间')


class SysLogininfor(Base):
    __tablename__ = 'sys_logininfor'
    __table_args__ = {'schema': 'public', 'comment': '系统访问记录'}

    info_id = Column(BigInteger, primary_key=True, comment='访问ID')
    user_name = Column(String(50), comment='用户账号')
    ipaddr = Column(String(128), comment='登录IP地址')
    login_location = Column(String(255), comment='登录地点')
    browser = Column(String(50), comment='浏览器类型')
    os = Column(String(50), comment='操作系统')
    status = Column(SmallInteger, index=True, comment='登录状态（0成功 1失败）')
    msg = Column(String(255), comment='提示消息')
    login_time = Column(DateTime, index=True, comment='访问时间')


class SysMenu(Base):
    __tablename__ = 'sys_menu'
    __table_args__ = {'schema': 'public', 'comment': '菜单权限表'}

    menu_id = Column(BigInteger, primary_key=True, comment='菜单ID')
    menu_name = Column(String(50), nullable=False, comment='菜单名称')
    parent_id = Column(BigInteger, comment='父菜单ID')
    order_num = Column(Integer, comment='显示顺序')
    path = Column(String(200), comment='路由地址')
    component = Column(String(255), comment='组件路径')
    query = Column(String(255), comment='路由参数')
    is_frame = Column(Integer, comment='是否为外链（0是 1否）')
    is_cache = Column(Integer, comment='是否缓存（0缓存 1不缓存）')
    menu_type = Column(CHAR(1), comment='菜单类型（M目录 C菜单 F按钮）')
    visible = Column(CHAR(1), comment='菜单状态（0显示 1隐藏）')
    status = Column(SmallInteger, comment='菜单状态（0正常 1停用）')
    perms = Column(String(100), comment='权限标识')
    icon = Column(String(100), comment='菜单图标')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class SysNotice(Base):
    __tablename__ = 'sys_notice'
    __table_args__ = {'schema': 'public', 'comment': '通知公告表'}

    notice_id = Column(Integer, primary_key=True, comment='公告ID')
    notice_title = Column(String(50), nullable=False, comment='公告标题')
    notice_type = Column(CHAR(1), nullable=False, comment='公告类型（1通知 2公告）')
    notice_content = Column(LargeBinary, comment='公告内容')
    status = Column(SmallInteger, comment='公告状态（0正常 1关闭）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(255), comment='备注')


class SysOperLog(Base):
    __tablename__ = 'sys_oper_log'
    __table_args__ = {'schema': 'public', 'comment': '操作日志记录'}

    oper_id = Column(BigInteger, primary_key=True, comment='日志主键')
    title = Column(String(50), comment='模块标题')
    business_type = Column(Integer, index=True, comment='业务类型（0其它 1新增 2修改 3删除）')
    method = Column(String(100), comment='方法名称')
    request_method = Column(String(10), comment='请求方式')
    operator_type = Column(Integer, comment='操作类别（0其它 1后台用户 2手机端用户）')
    oper_name = Column(String(50), comment='操作人员')
    dept_name = Column(String(50), comment='部门名称')
    oper_url = Column(String(255), comment='请求URL')
    oper_ip = Column(String(128), comment='主机地址')
    oper_location = Column(String(255), comment='操作地点')
    oper_param = Column(String(2000), comment='请求参数')
    json_result = Column(String(2000), comment='返回参数')
    status = Column(Integer, index=True, comment='操作状态（0正常 1异常）')
    error_msg = Column(String(2000), comment='错误消息')
    oper_time = Column(DateTime, index=True, comment='操作时间')
    cost_time = Column(BigInteger, comment='消耗时间')


class SysPost(Base):
    __tablename__ = 'sys_post'
    __table_args__ = {'schema': 'public', 'comment': '岗位信息表'}

    post_id = Column(BigInteger, primary_key=True, comment='岗位ID')
    post_code = Column(String(64), nullable=False, comment='岗位编码')
    post_name = Column(String(50), nullable=False, comment='岗位名称')
    post_sort = Column(Integer, nullable=False, comment='显示顺序')
    status = Column(SmallInteger, nullable=False, comment='状态（0正常 1停用）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class SysRole(Base):
    __tablename__ = 'sys_role'
    __table_args__ = {'schema': 'public', 'comment': '角色信息表'}

    role_id = Column(BigInteger, primary_key=True, comment='角色ID')
    role_name = Column(String(30), nullable=False, comment='角色名称')
    role_key = Column(String(100), nullable=False, comment='角色权限字符串')
    role_sort = Column(Integer, nullable=False, comment='显示顺序')
    data_scope = Column(CHAR(1),
                        comment='数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）')
    menu_check_strictly = Column(SmallInteger, comment='菜单树选择项是否关联显示')
    dept_check_strictly = Column(SmallInteger, comment='部门树选择项是否关联显示')
    status = Column(SmallInteger, nullable=False, comment='角色状态（0正常 1停用）')
    del_flag = Column(SmallInteger, comment='删除标志（0代表存在 2代表删除）')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class SysRoleDept(Base):
    __tablename__ = 'sys_role_dept'
    __table_args__ = {'schema': 'public', 'comment': '角色和部门关联表'}

    role_id = Column(BigInteger, primary_key=True, nullable=False, comment='角色ID')
    dept_id = Column(BigInteger, primary_key=True, nullable=False, comment='部门ID')


class SysRoleMenu(Base):
    __tablename__ = 'sys_role_menu'
    __table_args__ = {'schema': 'public', 'comment': '角色和菜单关联表'}

    role_id = Column(BigInteger, primary_key=True, nullable=False, comment='角色ID')
    menu_id = Column(BigInteger, primary_key=True, nullable=False, comment='菜单ID')


class SysUser(Base):
    __tablename__ = 'sys_user'
    __table_args__ = {'schema': 'public', 'comment': '用户信息表'}

    user_id = Column(BigInteger, primary_key=True, comment='用户ID')
    dept_id = Column(BigInteger, comment='部门ID')
    user_name = Column(String(30), nullable=False, comment='用户账号')
    nick_name = Column(String(30), nullable=False, comment='用户昵称')
    user_type = Column(String(2), comment='用户类型（00系统用户）')
    email = Column(String(50), comment='用户邮箱')
    phonenumber = Column(String(11), comment='手机号码')
    sex = Column(CHAR(1), comment='用户性别（0男 1女 2未知）')
    avatar = Column(String(100), comment='头像地址')
    password = Column(String(100), comment='密码')
    status = Column(SmallInteger, comment='帐号状态（0正常 1停用）')
    del_flag = Column(SmallInteger, comment='删除标志（0代表存在 2代表删除）')
    login_ip = Column(String(128), comment='最后登录IP')
    login_date = Column(DateTime, comment='最后登录时间')
    create_by = Column(String(64), comment='创建者')
    create_time = Column(DateTime, comment='创建时间')
    update_by = Column(String(64), comment='更新者')
    update_time = Column(DateTime, comment='更新时间')
    remark = Column(String(500), comment='备注')


class SysUserPost(Base):
    __tablename__ = 'sys_user_post'
    __table_args__ = {'schema': 'public', 'comment': '用户与岗位关联表'}

    user_id = Column(BigInteger, primary_key=True, nullable=False, comment='用户ID')
    post_id = Column(BigInteger, primary_key=True, nullable=False, comment='岗位ID')


class SysUserRole(Base):
    __tablename__ = 'sys_user_role'
    __table_args__ = {'schema': 'public', 'comment': '用户和角色关联表'}

    user_id = Column(BigInteger, primary_key=True, nullable=False, comment='用户ID')
    role_id = Column(BigInteger, primary_key=True, nullable=False, comment='角色ID')


class Token(Base):
    __tablename__ = 'token'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    application = Column(String(100))
    organization = Column(String(100))
    user = Column(String(100))
    code = Column(String(100), index=True)
    access_token = Column(Text)
    refresh_token = Column(Text)
    access_token_hash = Column(String(100), index=True)
    refresh_token_hash = Column(String(100), index=True)
    expires_in = Column(Integer)
    scope = Column(String(100))
    token_type = Column(String(100))
    code_challenge = Column(String(100))
    code_is_used = Column(Boolean)
    code_expire_in = Column(BigInteger)


class Transaction(Base):
    __tablename__ = 'transaction'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    display_name = Column(String(100))
    provider = Column(String(100))
    category = Column(String(100))
    type = Column(String(100))
    product_name = Column(String(100))
    product_display_name = Column(String(100))
    detail = Column(String(255))
    tag = Column(String(100))
    currency = Column(String(100))
    amount = Column(Float(53))
    return_url = Column(String(1000))
    user = Column(String(100))
    application = Column(String(100))
    payment = Column(String(100))
    state = Column(String(100))


class User(Base):
    __tablename__ = 'user'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100), index=True)
    updated_time = Column(String(100))
    deleted_time = Column(String(100))
    id = Column(String(100), index=True)
    external_id = Column(String(100), index=True)
    type = Column(String(100))
    password = Column(String(150))
    password_salt = Column(String(100))
    password_type = Column(String(100))
    display_name = Column(String(100))
    first_name = Column(String(100))
    last_name = Column(String(100))
    avatar = Column(String(500))
    avatar_type = Column(String(100))
    permanent_avatar = Column(String(500))
    email = Column(String(100), index=True)
    email_verified = Column(Boolean)
    phone = Column(String(100), index=True)
    country_code = Column(String(6))
    region = Column(String(100))
    location = Column(String(100))
    address = Column(Text)
    affiliation = Column(String(100))
    title = Column(String(100))
    id_card_type = Column(String(100))
    id_card = Column(String(100), index=True)
    homepage = Column(String(100))
    bio = Column(String(100))
    tag = Column(String(100))
    language = Column(String(100))
    gender = Column(String(100))
    birthday = Column(String(100))
    education = Column(String(100))
    score = Column(Integer)
    karma = Column(Integer)
    ranking = Column(Integer)
    balance = Column(Float(53))
    currency = Column(String(100))
    is_default_avatar = Column(Boolean)
    is_online = Column(Boolean)
    is_admin = Column(Boolean)
    is_forbidden = Column(Boolean)
    is_deleted = Column(Boolean)
    signup_application = Column(String(100))
    hash = Column(String(100))
    pre_hash = Column(String(100))
    access_key = Column(String(100))
    access_secret = Column(String(100))
    access_token = Column(Text)
    created_ip = Column(String(100))
    last_signin_time = Column(String(100))
    last_signin_ip = Column(String(100))
    github = Column(String(100))
    google = Column(String(100))
    qq = Column(String(100))
    wechat = Column(String(100))
    facebook = Column(String(100))
    dingtalk = Column(String(100))
    weibo = Column(String(100))
    gitee = Column(String(100))
    linkedin = Column(String(100))
    wecom = Column(String(100))
    lark = Column(String(100))
    gitlab = Column(String(100))
    adfs = Column(String(100))
    baidu = Column(String(100))
    alipay = Column(String(100))
    casdoor = Column(String(100))
    infoflow = Column(String(100))
    apple = Column(String(100))
    azuread = Column(String(100))
    azureadb2c = Column(String(100))
    slack = Column(String(100))
    steam = Column(String(100))
    bilibili = Column(String(100))
    okta = Column(String(100))
    douyin = Column(String(100))
    line = Column(String(100))
    amazon = Column(String(100))
    auth0 = Column(String(100))
    battlenet = Column(String(100))
    bitbucket = Column(String(100))
    box = Column(String(100))
    cloudfoundry = Column(String(100))
    dailymotion = Column(String(100))
    deezer = Column(String(100))
    digitalocean = Column(String(100))
    discord = Column(String(100))
    dropbox = Column(String(100))
    eveonline = Column(String(100))
    fitbit = Column(String(100))
    gitea = Column(String(100))
    heroku = Column(String(100))
    influxcloud = Column(String(100))
    instagram = Column(String(100))
    intercom = Column(String(100))
    kakao = Column(String(100))
    lastfm = Column(String(100))
    mailru = Column(String(100))
    meetup = Column(String(100))
    microsoftonline = Column(String(100))
    naver = Column(String(100))
    nextcloud = Column(String(100))
    onedrive = Column(String(100))
    oura = Column(String(100))
    patreon = Column(String(100))
    paypal = Column(String(100))
    salesforce = Column(String(100))
    shopify = Column(String(100))
    soundcloud = Column(String(100))
    spotify = Column(String(100))
    strava = Column(String(100))
    stripe = Column(String(100))
    tiktok = Column(String(100))
    tumblr = Column(String(100))
    twitch = Column(String(100))
    twitter = Column(String(100))
    typetalk = Column(String(100))
    uber = Column(String(100))
    vk = Column(String(100))
    wepay = Column(String(100))
    xero = Column(String(100))
    yahoo = Column(String(100))
    yammer = Column(String(100))
    yandex = Column(String(100))
    zoom = Column(String(100))
    metamask = Column(String(100))
    web3onboard = Column(String(100))
    custom = Column(String(100))
    webauthnCredentials = Column(LargeBinary)
    preferred_mfa_type = Column(String(100))
    recovery_codes = Column(String(1000))
    totp_secret = Column(String(100))
    mfa_phone_enabled = Column(Boolean)
    mfa_email_enabled = Column(Boolean)
    invitation = Column(String(100), index=True)
    invitation_code = Column(String(100), index=True)
    face_ids = Column(Text)
    ldap = Column(String(100))
    properties = Column(Text)
    roles = Column(Text)
    permissions = Column(Text)
    groups = Column(String(1000))
    last_signin_wrong_time = Column(String(100))
    signin_wrong_times = Column(Integer)
    managedAccounts = Column(LargeBinary)


class VerificationRecord(Base):
    __tablename__ = 'verification_record'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    remote_addr = Column(String(100))
    type = Column(String(10))
    user = Column(String(100), nullable=False)
    provider = Column(String(100), nullable=False)
    receiver = Column(String(100), nullable=False, index=True)
    code = Column(String(10), nullable=False)
    time = Column(BigInteger, nullable=False)
    is_used = Column(Boolean)


class Webhook(Base):
    __tablename__ = 'webhook'
    __table_args__ = {'schema': 'public'}

    owner = Column(String(100), primary_key=True, nullable=False)
    name = Column(String(100), primary_key=True, nullable=False)
    created_time = Column(String(100))
    organization = Column(String(100), index=True)
    url = Column(String(200))
    method = Column(String(100))
    content_type = Column(String(100))
    headers = Column(Text)
    events = Column(String(1000))
    is_user_extended = Column(Boolean)
    single_org_only = Column(Boolean)
    is_enabled = Column(Boolean)
